package com.m3839.sdk.common.core;

import static com.m3839.sdk.common.core.Constant.ENV_PAY;
import static com.m3839.sdk.common.core.Constant.NET_ERROR_DIALOG_CONTENT;
import static com.m3839.sdk.common.core.Constant.NET_ERROR_DIALOG_TIPS;

import android.content.Context;

/**
 * 描述信息: SDK相关全局配置
 *
 * @author xuzhiwei
 * @create 2020/8/3
 */
public class SdkConfiguration {

  /**
   * 全局application context
   */
  private static Context sAppContext;

  /**
   * 当前app的上下文
   */
  private static String sGameId;

  /**
   * 当前游戏包名
   */
  private static String sPackageName;

  /**
   * 当前游戏横竖屏
   */
  private static int sOrientation;

  /**
   * 网络异常默认弹窗文案
   */
  private static String netErrorContent = NET_ERROR_DIALOG_CONTENT;

  /**
   * 网络异常默认温馨提示
   */
  private static String netErrorTips = NET_ERROR_DIALOG_TIPS;

  /**
   * 用来判断用户防沉迷兜底弹窗的开关状态
   */
  private static int fcmStatus;

  /**
   * 用来判断当前这个配置是用在哪个sdk
   */
  private static int sdkEnv = ENV_PAY;



  public static void init (Context context, String gameId, int orientation) {
    init(context, gameId);
    sOrientation = orientation;
  }

  public static void init(Context context, String gameId) {
     sAppContext = context.getApplicationContext();
    sGameId = gameId;
  }

  /**
   * 获取当前app的上下文
   * @return
   */
  public static Context getAppContext() {
    return sAppContext;
  }

  /**
   * 获取当前gameId配置
   * @return
   */
  public static String getGameId() {
    return sGameId;
  }

  public static int getOrientation() {
    return sOrientation;
  }


  public static String getPackageName(){
      if (sPackageName == null && sAppContext != null) {
        sPackageName = sAppContext.getPackageName();
      }
      return sPackageName;
  }

  public static void setNetErrorContent(String content) {
    SdkConfiguration.netErrorContent = content;
  }

  public static void setNetErrorTips(String tips) {
    SdkConfiguration.netErrorTips = tips;
  }

  public static void setFcmStatus(int fcmStatus) {
    SdkConfiguration.fcmStatus = fcmStatus;
  }

  public static String getNetErrorContent() {
    return netErrorContent;
  }

  public static String getNetErrorTips() {
    return netErrorTips;
  }

  public static int getFcmStatus() {
    return fcmStatus;
  }

  public static String getSDKVersion() {
    return "1.0.4.0";
  }

  public static void setSdkEnv(int env) {
    SdkConfiguration.sdkEnv = env;
  }

  public static int getSdkEnv(){
    return sdkEnv;
  }
}
